﻿@model IEnumerable<PotentialRentals.Models.Rental>

@if (Model.Any())
{
<table width="100%">
    @foreach (var rental in Model)
    {
        <tr>
            <td width="40" style="border: 0;">
                @Ajax.ActionLink("Add", "Add", new { id = rental.RentalId }, new AjaxOptions { HttpMethod = "POST", OnSuccess = "refreshLists()" })
                @if (User.Identity.IsAuthenticated && rental.Owner.UserName == User.Identity.Name)
                {
                    @Ajax.ActionLink("Delete", "Delete", new { id = rental.RentalId }, new AjaxOptions { HttpMethod = "POST", OnSuccess = "refreshLists()" })
                }
            </td>
            <td width="175">
                @if (rental.Name != null)
                {
                    <span class="rental-name">@rental.Name</span><br />
                }
                @if (rental.Address.Name != null)
                {
                    <span class="address-name">@rental.Address.Name</span><br />
                }
                <span class="address">@rental.Address.Street @rental.Address.City, @rental.Address.State.Abbr</span><br />
                <span class="bedbath">@String.Format("{0}br/{1:0.##}ba", rental.Bedrooms, rental.Bathrooms)</span>
            </td>
            <td width="140">
                @Html.Raw(String.Format("<a href='mailto:{0}'>{0}</a>", rental.Email))<br />
                @rental.Phone
            </td>
            <td width="50">
                <span class="rent">$@rental.Rent</span><br />
                <span class="deposit">Dep:&nbsp;$@rental.Deposit</span>
            </td>
            <td style="vertical-align: top;">
                Amenities
            </td>
        </tr>
    }
</table>
}
else
{
    <div style="text-align:center;">No Rentals could be found meeting your criteria.</div>
}